const { sqlPromise } = require("../db/sqlPromise");
const turnTree = require("../util/turnTree");

exports.getRights = async (req, res) => {
  let sql =
    "select ps_id as id, ps_name as authName, ps_level as level, ps_pid as pid from sp_permission";
  let result = await sqlPromise(sql, [req.body.username]);
  if (req.query.type == "tree") {
    result = turnTree(result);
  }
  res.send({
    data: result,
    meta: {
      msg: "获取权限列表成功",
      status: 200,
    },
  });
};
